const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LifecycleDemoPlugin = require("./LifecycleDemoPlugin");

module.exports = {
  entry: './src/index.js', // 入口文件
  output: {
    filename: 'main.js', // 输出文件名
    path: path.resolve(__dirname, 'dist'), // 输出文件夹
    clean: true, // 每次打包先清理dist目录
  },
  module: {
    rules: [
      {
        test: /\.css$/,  // 处理CSS
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /\.(png|jpg|gif)$/, // 处理图片
        type: 'asset/resource',
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './index.html', // 以根目录下的index.html为模板
    }),

    new LifecycleDemoPlugin()
  ],
  mode: 'development', // 开发模式
  devtool: 'inline-source-map', // 方便调试
};
